(ns acst.utils.cors
  (:require [ring.util.response :as resp]))

(defn create-headers [response access-control-map]
  (let [x (reduce #(merge %1 (resp/header %1 (first %2) (second %2))) response access-control-map)]
    x))

(defn wrap-cors-headers [handler access-control-map]
  (fn [request]
    (if-let [response (handler request)]
      (create-headers response access-control-map))))


